Skip to content

feat: Adds openTelemetry Collector resource#2520

Merged
myakove merged 3 commits into
RedHatQE:mainfrom
kpunwatk:otel_operator_resource
Sep 5, 2025
Merged

feat: Adds openTelemetry Collector resource#2520
myakove merged 3 commits into
RedHatQE:mainfrom
kpunwatk:otel_operator_resource

Conversation

@kpunwatk

@kpunwatk kpunwatk commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Adds openTelemetry resource to the wrapper

Short description:
More details:
What this PR does / why we need it:
Which issue(s) this PR fixes:
Special notes for reviewer:
Bug:

Summary by CodeRabbit

  • New Features
    • Manage OpenTelemetry Collector resources in namespaces.
    • Configure collector settings: config, management state, mode, replicas, and resource specs.
    • Validation to prevent incomplete collector configurations.
    • Adds compatibility with the opentelemetry.io API group for smoother OpenTelemetry integration.

@coderabbitai

coderabbitai Bot commented Sep 3, 2025

Copy link
Copy Markdown

Walkthrough

Adds a NamespacedResource-backed OpenTelemetryCollector resource that builds and validates its spec and registers the opentelemetry.io API group constant.

Changes

Cohort / File(s) Summary of modifications
New OpenTelemetryCollector resource
ocp_resources/open_telemetry_collector.py
Added OpenTelemetryCollector(NamespacedResource) with api_group = NamespacedResource.ApiGroup.OPENTELEMETRY_IO; __init__ stores config, management_state, mode, replicas, resources; to_dict() validates required fields (config, management_state) and builds spec including optional fields when provided.
API group constant addition
ocp_resources/resource.py
Added ApiGroup constant OPENTELEMETRY_IO = "opentelemetry.io".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • myakove
  • rnetser
  • dbasunag

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c03e5de and 84cc14e.

📒 Files selected for processing (1)
  • ocp_resources/resource.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ocp_resources/resource.py
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kpunwatk

kpunwatk commented Sep 3, 2025

Copy link
Copy Markdown
Contributor Author

Hi @adolfo-ab @myakove @rnetser please review this PR, Thanks!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
ocp_resources/open_telemetry_collector.py (1)

71-71: Mask potentially sensitive spec.config in logs.

Collector configs often embed credentials/endpoints. Hashing this field in log output avoids accidental leakage.

     # End of generated code
+
+    @property
+    def keys_to_hash(self) -> list[str]:
+        # Mask the entire collector config in logs
+        return ["spec>config"]
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 570b070 and df41268.

📒 Files selected for processing (2)
  • ocp_resources/open_telemetry_collector.py (1 hunks)
  • ocp_resources/resource.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
ocp_resources/open_telemetry_collector.py (2)
ocp_resources/resource.py (4)
  • NamespacedResource (1532-1642)
  • ApiGroup (466-574)
  • to_dict (735-739)
  • to_dict (1640-1642)
ocp_resources/exceptions.py (1)
  • MissingRequiredArgumentError (5-10)
🔇 Additional comments (3)
ocp_resources/resource.py (1)

533-533: LGTM: API group added correctly.

OPENTELEMETRY_IO constant matches the expected API group and integrates cleanly with the dynamic version discovery.

ocp_resources/open_telemetry_collector.py (2)

14-14: LGTM: Correct API group assignment.

Using NamespacedResource.ApiGroup.OPENTELEMETRY_IO is the right hook for this CRD.


49-54: Fix error messages and avoid forcing management_state.

  • Use parameter names without self. in MissingRequiredArgumentError for clearer UX.
  • Don’t raise if management_state is omitted; include it only when provided to avoid generating invalid specs for distributions that don’t support it.
-        if not self.kind_dict and not self.yaml_file:
-            if self.config is None:
-                raise MissingRequiredArgumentError(argument="self.config")
-
-            if self.management_state is None:
-                raise MissingRequiredArgumentError(argument="self.management_state")
+        if not self.kind_dict and not self.yaml_file:
+            if self.config is None:
+                raise MissingRequiredArgumentError(argument="config")
⛔ Skipped due to learnings
Learnt from: servolkov
PR: RedHatQE/openshift-python-wrapper#2490
File: ocp_resources/route_advertisements.py:53-65
Timestamp: 2025-08-11T16:42:29.245Z
Learning: In the openshift-python-wrapper project, when raising MissingRequiredArgumentError, the convention is to include the "self." prefix in the argument name (e.g., `MissingRequiredArgumentError(argument="self.advertisements")`). This pattern is established in the code generator template at `class_generator/manifests/class_generator_template.j2` and followed consistently across most resource classes.

Comment thread ocp_resources/open_telemetry_collector.py
Comment thread ocp_resources/open_telemetry_collector.py
Comment thread ocp_resources/open_telemetry_collector.py
@myakove

myakove commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator

/retest all

@myakove

myakove commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator

/retest tox

@myakove

myakove commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator

/retest all

@myakove myakove changed the title Adds openTelemetry Collector resource feat: Adds openTelemetry Collector resource Sep 3, 2025
@myakove

myakove commented Sep 3, 2025

Copy link
Copy Markdown
Collaborator

@kpunwatk pre-commit check failed, Please fix it
https://github.com/RedHatQE/openshift-python-wrapper/blob/main/README.md#code-check

@myakove myakove enabled auto-merge (squash) September 3, 2025 20:12
	new file:   ocp_resources/open_telemetry_collector.py
	modified:   ocp_resources/resource.py

	new file:   ocp_resources/open_telemetry_collector.py
	modified:   ocp_resources/resource.py
auto-merge was automatically disabled September 4, 2025 08:38

Head branch was pushed to by a user without write access

@kpunwatk kpunwatk force-pushed the otel_operator_resource branch from df41268 to c03e5de Compare September 4, 2025 08:38
@kpunwatk

kpunwatk commented Sep 4, 2025

Copy link
Copy Markdown
Contributor Author

Done @myakove , thanks!

@myakove myakove enabled auto-merge (squash) September 4, 2025 09:52
@myakove

myakove commented Sep 4, 2025

Copy link
Copy Markdown
Collaborator

/approve
/lgtm

@kpunwatk

kpunwatk commented Sep 4, 2025

Copy link
Copy Markdown
Contributor Author

/verified

@kpunwatk

kpunwatk commented Sep 5, 2025

Copy link
Copy Markdown
Contributor Author

/verified

@myakove

myakove commented Sep 5, 2025

Copy link
Copy Markdown
Collaborator

/approve
/lgtm

@myakove myakove merged commit 20f0030 into RedHatQE:main Sep 5, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants